import {
  q as u,
  p as ae,
  ap as se,
  X as A,
  f as ie,
  H as ue,
  av as N,
  aw as ne,
  k as t,
  l,
  m as a,
  ax as L,
  as as c,
  az as re,
  at as E,
  ay as oe
} from "./index-b50e6ef9.js";
import { d as de, c as V } from "./order-9978affc.js";
function y(m) {
  return (
    typeof m == "function" ||
    (Object.prototype.toString.call(m) === "[object Object]" && !oe(m))
  );
}
function me(m) {
  const b = u([]),
    F = u([]),
    W = u([]),
    B = u([]),
    w = u({}),
    p = u(!0);
  u({}), ae();
  const g = u(1),
    h = u(10),
    f = u([]),
    _ = u(),
    C = u(),
    x = u(""),
    I = u(""),
    Y = se("reload"),
    D = A({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    J = A({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    M = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "ID",
        prop: "order_id",
        minWidth: 80,
        formatter: ({ order_id: e }) => `1${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({
          wares_name: e,
          store_name: s,
          store_code: o,
          notes: r,
          activity: d,
          remarks: i,
          size: n
        }) =>
          t("div", null, [
            t("div", null, [e]),
            s
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  y(s) ? s : { default: () => [s] }
                )
              : "",
            o
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [a("门店码:"), o] }
                )
              : "",
            t("div", null, [
              r
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    y(r) ? r : { default: () => [r] }
                  )
                : ""
            ]),
            t("div", null, [
              d == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [a("已赠送")] }
                  )
                : ""
            ]),
            t("div", null, [
              i
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    y(i) ? i : { default: () => [i] }
                  )
                : ""
            ]),
            t("div", null, [
              n
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    y(n) ? n : { default: () => [n] }
                  )
                : ""
            ])
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      {
        label: "支付金额",
        prop: "pay_price",
        minWidth: 100,
        formatter: ({ pay_price: e }) =>
          t("div", { style: "color:#59AB74" }, [e])
      },
      { label: "积分折扣", prop: "hock_price", minWidth: 80 },
      { label: "折扣支付", prop: "other_price", minWidth: 80 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 80,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "积分";
          if (e == 2) return "微信";
          if (e == 3) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      {
        label: "内含数量",
        prop: "all_bottle",
        minWidth: 100,
        formatter: ({ all_bottle: e, wares_unit: s }) => e + s
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: s }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && s != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递")] }
            );
          if (e == 3 && s == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提")] }
            );
        }
      },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => L(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "操作", fixed: "right", width: 280, slot: "operation" }
    ],
    z = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "phone", minWidth: 120 },
      { label: "收件人姓名", prop: "name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: s }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && s != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递")] }
            );
          if (e == 3 && s == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提")] }
            );
        }
      },
      { label: "内含数量", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => L(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "衣服规格", prop: "size", minWidth: 100 },
      { label: "订单备注", prop: "remarks", minWidth: 100 },
      { label: "备注", prop: "notes", minWidth: 100 },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    O = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("暂无")] }
            );
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星合伙人")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星合伙人")] }
            );
          if (e == 3)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星合伙人")] }
            );
          if (e == 4)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星合伙人")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("五星合伙人")] }
            );
          if (e == 6)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星联创")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星联创")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星联创")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星联创")] }
            );
          if (e == 10)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星董事")] }
            );
          if (e == 11)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星董事")] }
            );
          if (e == 12)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: s }) => e || s
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已发放")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [a("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    R = ie(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function H(e) {
    const s = { order_id: e.order_id },
      o = JSON.stringify(s),
      d = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(o)) },
      i = await de(d);
    i.code == 200 &&
      ((F.value = i.data.income),
      (W.value = i.data.dispel),
      (B.value = i.data.freeze),
      (w.value = i.data.indent));
  }
  async function U(e) {
    re(e);
  }
  async function j(e) {
    const s = { id: e.id },
      o = JSON.stringify(s),
      d = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(o)) },
      i = await questionDelete(d);
    i.code == 200
      ? (E("删除成功", { type: "success" }), Y())
      : E(i.msg, { type: "error" });
  }
  function T() {}
  function k(e) {
    (h.value = e), v(void 0, e);
  }
  function $(e) {
    (g.value = e), v(e, void 0);
  }
  function q(e) {}
  function X(e) {
    (J.text = `正在加载第${e}页...`),
      (p.value = !0),
      N(600).then(() => {
        p.value = !1;
      });
  }
  async function G(e, s, o = [], r, d, i, n) {
    (f.value = []),
      o.map(ee => {
        const te = ee,
          le = new Date(te);
        f.value.push(
          le.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (p.value = !0),
      (_.value = e),
      (C.value = d),
      (x.value = i),
      (I.value = n);
    const Q = {
        page: g.value,
        pagesize: h.value,
        status: 2,
        user_phone: isNaN(s) ? void 0 : s,
        user_id: isNaN(r) ? void 0 : r,
        user_name: isNaN(s) ? s : void 0,
        start: f.value[0],
        end: f.value[1],
        store_code: d,
        wares_unit: i == "no" ? void 0 : i,
        all_bottle: n || void 0,
        action: "add_time"
      },
      Z = JSON.stringify(Q),
      P = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(Z)) },
      { data: S } = await V(P);
    (b.value = S.indent.data),
      (D.total = S.indent.total),
      setTimeout(() => {
        p.value = !1;
      }, 500);
  }
  async function v(e = g.value, s = h.value) {
    const o = {
        page: e,
        pagesize: s,
        status: "2",
        start: f.value[0],
        end: f.value[1],
        store_code: C.value,
        wares_unit: x.value == "no" ? void 0 : x.value,
        all_bottle: I.value || void 0,
        action: "add_time"
      },
      r = JSON.stringify(o),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(r)) },
      n = await V(i);
    n.code === 200
      ? ((b.value = n.data.indent.data),
        (D.total = n.data.indent.total),
        setTimeout(() => {
          p.value = !1;
        }, 500))
      : E(n.msg, { type: "error" });
  }
  const K = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ue(() => {
      N().then(() => {
        const { setWatermark: e } = ne(m.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        v();
    }),
    {
      loading: p,
      columns: M,
      dataList: b,
      userColumns: O,
      pagination: D,
      userDatilListDisple: W,
      userDatilListFreeze: B,
      buttonClass: R,
      userDatilList: F,
      orderInfo: w,
      columnsTable: z,
      count: g,
      pageCount: h,
      formattedDate: f,
      typeCount: _,
      handleLookUserDatil: H,
      onSearch: G,
      resetForm: K,
      handleaddUser: T,
      handleUpdate: U,
      handleDelete: j,
      handleSizeChange: k,
      handleCurrentChange: $,
      handleSelectionChange: q,
      onCurrentChange: X
    }
  );
}
export { me as useRole };
